package io.zcoder.innoway.activities;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.zcoder.innoway.R;
import io.zcoder.innoway.commons.Constants;

public class AboutUsActivity extends BaseActivity {

    @OnClick(R.id.faq)
    void onFAQ() {
        Intent intent = new Intent(this, WebViewActivity.class);
        intent.putExtra(Constants.URL_EXTRAS, Constants.URL_FAQ);
        startActivity(intent);
    }

    @OnClick(R.id.terms_of_use)
    void term() {
        Intent intent = new Intent(this, WebViewActivity.class);
        intent.putExtra(Constants.URL_EXTRAS, Constants.URL_TERM);
        startActivity(intent);
    }

    @OnClick(R.id.privacy_policy)
    void policy() {
        Intent intent = new Intent(this, WebViewActivity.class);
        intent.putExtra(Constants.URL_EXTRAS, Constants.URL_POLICY);
        startActivity(intent);
    }

    @OnClick(R.id.share_on_wechat)
    void shareWeChat() {
    }

    @OnClick(R.id.share_on_fb)
    void shareFB() {
        String urlToShare = "https://play.google.com/store/apps/details?id=" + getPackageName();

        try {
            Intent intent1 = new Intent();
            intent1.setClassName("com.facebook.katana", "com.facebook.katana.activity.composer.ImplicitShareIntentHandler");
            intent1.setAction("android.intent.action.SEND");
            intent1.setType("text/plain");
            intent1.putExtra("android.intent.extra.TEXT", urlToShare);
            startActivity(intent1);
        } catch (Exception e) {
            String sharerUrl = "https://www.facebook.com/sharer/sharer.php?u=" + urlToShare;
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(sharerUrl));
            startActivity(intent);
        }
    }

    @OnClick(R.id.review_google_play)
    void review() {
        final String appPackageName = getPackageName();
        try {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
        } catch (android.content.ActivityNotFoundException anfe) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
        }
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_about_us_activity);
        ButterKnife.bind(this);
        showBack(true);
        setTitle(getString(R.string.about_us));
    }
}
